/*
 * Copyright (C) 2007 Google Inc.
 * Copyright (C) 2012 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package dagger;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Annotates methods of a module to create a provider method binding. The
 * method's return type is bound to its returned value. The object graph will
 * pass dependencies to the method as parameters.
 * 注释模块的方法以创建提供程序方法绑定。方法的返回类型绑定到它的返回值。对象图将依赖项作为参数传递给方法。
 * @author Bob Lee
 */
@Documented @Target(METHOD) @Retention(RUNTIME)
public @interface Provides {
  /** The type of binding into which the return type of the annotated method contributes.
   * 带注释的方法的返回类型提供的绑定类型。
   */
  enum Type {
    /**
     * The method is the only one which can produce the value for the specified return type. This
     * is the default behavior.
     * 该方法是唯一可以为指定的返回类型生成值的方法。这是默认的行为。
     */
    UNIQUE,

    /**
     * The method's return type forms the generic type argument of a {@code Set<T>}, and the
     * returned value is contributed to the set. The object graph will pass dependencies to the
     * method as parameters. The {@code Set<T>} produced from the accumulation of values will be
     * immutable.
     *
     * 方法的返回类型形成了一个集合<T>的泛型类型参数，返回的值被贡献给集合。
     * 对象图将依赖项作为参数传递给方法。
     * 从值的累积中产生的Set<T>将是不可变的。
     */
    SET,

    /**
     * Like {@link #SET}, except the method's return type is {@code Set<T>}, where any values are
     * contributed to the set. An example use is to provide a default empty set binding, which is
     * otherwise not possible using {@link #SET}.
     *
     * 与SET类似，除了方法的返回类型是SET <T>，其中任何值都贡献给SET。
     * 一个使用示例是提供一个默认的空集绑定，否则使用SET是不可能的。
     */
    SET_VALUES;
  }

  Type type() default Type.UNIQUE;
}
